<template>
	<view class="greyBox">
		<view class="propertyCard">
			<view class="top">
				<view class="title">资产总额(元)</view>
				<view class="propertyBox">
					<view class="item">
						<view class="name">会员金额(元)</view>
						<view class="num">{{memberInfo.sumAmount}}</view>
					</view>
					<view class="item">
						<view class="name">剩余金额(元)</view>
						<view class="num">{{memberInfo.currentAmount}}</view>
					</view>
				</view>
			</view>
			<view class="bottom">
				<view class="icon">
					<u-icon name="https://supply.zhongyimotor.com/upload/applet/icon_time_supplier@2x.png"
						size="32"></u-icon>
				</view>
				<view class="content">会员有效期：无</view>
			</view>
		</view>
		<view class="logList">
			<view class="item" v-for="(item,index) in consumptionLog" v-key="index">
				<view class="content">
					<view class="num"><text>¥</text> {{item.amount}}</view>
					<view class="dateTime">消费时间：{{item.timeCreate}}</view>
				</view>
			</view>
			<u-empty src="https://supply.zhongyimotor.com/upload/applet/maorder_kong_img@2x.png" icon-size="296"
				v-if="consumptionLog.length == 0" text="暂无数据" margin-top="200"></u-empty>
			<u-toast ref="uToast" />
		</view>

		<u-no-network></u-no-network>
	</view>
</template>

<script>
	import moment from "moment"
	export default {
		data() {
			return {
				consumptionLog: [],
				memberInfo: {}
			}
		},
		onShow() {
			this.getMemberInfo();

		},
		methods: {
			async getMemberInfo() {
				let that = this
				await that.$api.getMemberInfo().then(res => {
					if (res.result != null) {
						that.memberInfo = res.result
						uni.setStorage({
							key: 'currentAmount',
							data: that.memberInfo.currentAmount,
						});
						that.memberInfo.sumAmount = that.unitConverter(that.memberInfo.sumAmount);
						that.memberInfo.currentAmount = that.unitConverter(that.memberInfo.currentAmount);
					}
				})
				let params = {
					current: 1,
					size: 999
				}
				await that.$api.getConsumptionLog(params).then(res => {
					that.consumptionLog = res.result.records;
				})
			},
		}
	};
</script>

<style scoped lang="scss">
	.propertyCard {
		width: 690rpx;
		background: linear-gradient(270deg, #53576C 0%, #292C3A 100%);
		border-radius: 24rpx;
		margin: 20rpx auto;
		color: #F0CFB3;
		font-size: 26rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 500;

		.bottom {
			width: 690rpx;
			height: 84rpx;
			line-height: 84rpx;
			background: #5E6177;
			border-radius: 0rpx 0rpx 24rpx 24rpx;
			display: flex;
			padding-left: 40rpx;

			.icon {
				margin-right: 10rpx;
				margin-top: 8rpx;
			}
		}

		.top {
			padding: 36rpx 40rpx;

			.title {
				margin-bottom: 30rpx;
			}

			.propertyBox {
				display: flex;

				.item {
					margin: 0 auto;

					.num {
						margin-top: 10rpx;
						font-size: 44rpx;
						font-family: DINAlternate, DINAlternate;
						font-weight: bold;
						color: #F0CFB3;
						line-height: 52rpx;

					}
				}
			}
		}

	}

	.logList {
		.item {
			width: 690rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			padding: 30rpx 40rpx;
			margin: 20rpx auto;

			.dateTime {
				font-size: 26rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				color: #9D9D9D;
				line-height: 48rpx;
				margin-left: auto;
			}

			.content {
				display: flex;

				.name {
					font-size: 30rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					color: #4D4D4D;
					line-height: 42rpx;
				}

				.num {
					font-size: 40rpx;
					font-family: DINAlternate, DINAlternate;
					font-weight: bold;
					color: #505050;
					line-height: 48rpx;

					text {
						font-size: 26rpx;
						font-family: PingFangSC, PingFang SC;
						font-weight: 600;
						color: #505050;
						line-height: 36rpx;
					}
				}
			}
		}
	}
</style>